﻿using Microsoft.Extensions.DependencyInjection;
using Quartz.Impl;
using Quartz.Spi;
using Quartz;
using shop.Web.PlanTask;

namespace shop.Web
{
    public partial class Startup
    {
        /// <summary> 配置定时任务, 这是 Startup 的一个函数  </summary>
        private void ConfigPlanJob(IServiceCollection services)
        {

            //Quartz 日志
            //Quartz.Logging.LogProvider.SetCurrentLogProvider(new QuartzLogFactory()); //使用自定义日志, 但是不能取消默认的输出日志
            Quartz.Logging.LogProvider.IsDisabled = true;   //禁用日志


            services.AddSingleton<IJobFactory, SingletonJobFactory>();
            services.AddSingleton<ISchedulerFactory, StdSchedulerFactory>();






            //注册作业和触发器
            services.AddSingleton<SyncBiJob>();
            //services.AddSingleton(new JobSchedule(typeof(SyncBiJob), "0 0 3 * * ?")); //  
            services.AddSingleton(new JobSchedule(typeof(SyncBiJob), "0 30 23 * * ?")); //  
            //services.AddSingleton(new JobSchedule(typeof(SyncBiJob), "0 57 21 * * ?")); //  

            services.AddSingleton(new JobSchedule(typeof(DealRepeatTradeJob), "0 30 23 * * ?")); //  


            //services.AddSingleton<CloseSalesDeliveryJob>();
            //services.AddSingleton(new JobSchedule(typeof(CloseSalesDeliveryJob), "0 5 7 * * ?")); //  



            services.AddHostedService<QuartzHostedService>();

        }




    }
}
